<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class RewardOrderModel{ 
    protected $CI;
    private $pageSize = 10;
    public function __construct(){
        $this->CI =& get_instance();
        $this->CI->load->database();
    }
    /**
     * [queryByUserIdAndRelaseId description]
     * @param  [type] $userId    [description]
     * @param  [type] $releaseId [description]
     * @return [type]            [description]
     */
    public function queryByUserIdAndRelaseId($userId,$releaseId,$orderAmount,$orderType){
        log_message("info","queryByUserIdAndRelaseId,userId:$userId,releaseId:$releaseId,orderAmount:$orderAmount,orderType:$orderType");
        $query = $this->CI->db->select("id,status,order_number")
            ->get_where('user_reward_order', [
                'user_id'=>$userId,
                'release_order_id'=>$releaseId,
                'order_amount'=>$orderAmount,
                'order_type'=>$orderType,
            ], 1, 0);
            // echo $this->CI->db->last_sql();exit;
            // var_dump($query);exit;
        $result = $query->row(); 
        return $result;
    }

    /**
     * [queryByUserIdAndType description]
     * @param  [type] $userId    [description]
     * @param  [type] $releaseId [description]
     * @return [type]            [description]
     */
    public function queryByUserIdAndType($userId,$orderType){
        $query = $this->CI->db->select("id,status,order_number")
            ->get_where('user_reward_order', [
                'user_id'=>$userId,
                'order_type'=>$orderType,
            ], 1, 0);
        $result = $query->row(); 
        return $result;
    }
  
}